package com.common.util;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 允许跨域拦截设置
 * @author zhongqiu
 * @date 2016年5月27日
 * @time 上午8:37:03
 */
public class WebCosLongInterceptor extends HandlerInterceptorAdapter {
	
	/**
	 * 跨域设置头信息
	 */
	private String allowCosHeader;

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		if(allowCosHeader != null && !"".equals(allowCosHeader)){
			response.setHeader("Access-Control-Allow-Origin",allowCosHeader);
		}
		return super.preHandle(request, response, handler);
	}

	public String getAllowCosHeader() {
		return allowCosHeader;
	}

	public void setAllowCosHeader(String allowCosHeader) {
		this.allowCosHeader = allowCosHeader;
	}
	
	
	
}
